package avatar.data
{
	import flash.utils.Dictionary;
	

	public class AvatarLayouData
	{
		private var _data : Dictionary;
		public function AvatarLayouData(embedData : String)
		{
			if(!embedData)return;
			_data = new Dictionary(true);
			var arr : Array = embedData.split("|");
			for each(var str : String in arr)
			{
				var obj : Object = solveItemData(str);
				_data[obj.k] = obj;
			}
//			trace(embedData);
		}
		public function getCellByKey(frameX : int,frameY:int) : Object
		{
			return _data[frameX + "_" + frameY];
		}
		/**
		 * x:1210,y:1427,w:307,h:209,px:33,py:87,k:7_4 
		 * 
		 */		
		private function solveItemData(value : String) : Object
		{
			var temp : Array = value.split(",");
			var obj : Object = {};
			for each(var key : String in temp)
			{
				var inx : int = key.indexOf(":");
				obj[key.substr(0,inx)] = key.substr(inx+1);
			}
			temp = null;
			return obj;
		}
	}
}